﻿using BDQN.Dtos;
using BDQN.IBLL;
using Microsoft.AspNetCore.Mvc;
using X.PagedList;
using X.PagedList.Extensions;
using BDQN.Commons;
using BDQN.WebApp.Areas.manage.Controllers;

namespace BDQN.WebApp.Areas.manage.Controllers
{
    [Area("manage")]
    public class RolesManageController : Controller
    {
        private IRolesBll _rolesBll;
        public RolesManageController(IRolesBll rolesBll)
        {
            _rolesBll = rolesBll;
        }
        [HttpGet]
        public async Task<IActionResult > List(string? search,int? pageIndex)
        {
            search = search ?? string.Empty;
            int currentIndex = pageIndex ?? 1;
            var data = await _rolesBll.GetRolesAsync(search);
            IPagedList<RolesDto> pages = data.ToPagedList(currentIndex,PageConfig.PageSize);
            ViewBag.Search = search;
            ViewBag.PageIndex = currentIndex;
            return View(pages);
        }
    }
}
